import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'

const baseUrl = CommonConfig.cutterUrl + '/v1'

/**
 * 获取刀具报废列表
 * @param params
 * @returns {Promise<unknown>}
 */
function getScrapList (params) {
  const url = `${baseUrl}/report/scrapping`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res.data)
  })
}

/**
 * 导出刀具报废报表
 * @param params
 * @returns {Promise<unknown>}
 */
function exportScrapList (params) {
  const url = `${baseUrl}/report/scrapping/excel:export`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res)
  })
}
/**
 * 获取刀具采购列表
 * @param params
 * @returns {Promise<unknown>}
 */
function getPurchaseList (params) {
  const url = `${baseUrl}/report/purchase`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res.data)
  })
}

/**
 * 导出刀具采购报表
 * @param params
 * @returns {Promise<unknown>}
 */
function exportPurchaseList (params) {
  const url = `${baseUrl}/report/purchase/export`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res)
  })
}

/**
 * 获取刀具采购列表
 * @param params
 * @returns {Promise<unknown>}
 */
function getInspectionList (params) {
  const url = `${baseUrl}/report/inspection`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res.data)
  })
}

/**
 * 导出刀具采购报表
 * @param params
 * @returns {Promise<unknown>}
 */
function exportInspectionList (params) {
  const url = `${baseUrl}/report/inspection/export`
  return axiosInstance.get(url, { params }).then(res => {
    return Promise.resolve(res)
  })
}

export default {
  getScrapList,
  exportScrapList,
  getPurchaseList,
  exportPurchaseList,
  getInspectionList,
  exportInspectionList
}
